package com.algo.rpc.business;

import com.algo.rpc.server.ServiceProvider;

import java.util.ArrayList;
import java.util.List;

@ServiceProvider(serviceInteface = UserService.class)
public class UserServiceImpl implements UserService {

    private static UserInfo userInfo;

    static {
        List<UserInfo.SubInfo> subInfos = new ArrayList<UserInfo.SubInfo>();
        subInfos.add(new UserInfo.SubInfo("subField1"));
        subInfos.add(new UserInfo.SubInfo("subField2"));
        subInfos.add(new UserInfo.SubInfo("subField3"));

        userInfo = new UserInfo("于纯纯", 28, subInfos);
    }


    @Override
    public boolean updateUserName(String userName) {
        userInfo.setUserName(userName);
        return true;
    }

    @Override
    public List<UserInfo.SubInfo> getSubInfos() {
        return userInfo.getSubInfoList();
    }

    @Override
    public UserInfo getUserInfo() {
        return userInfo;
    }
}
